{
 "cells": [
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "# 描述\n",
    "Python break语句，就像在C语言中，打破了最小封闭for或while循环。\n",
    "\n",
    "break语句用来终止循环语句，即循环条件没有False条件或者序列还没被完全递归完，也会停止执行循环语句。\n",
    "\n",
    "break语句用在while和for循环中。\n",
    "\n",
    "如果您使用嵌套循环，break语句将停止执行最深层的循环，并开始执行下一行代码。\n",
    "\n",
    "# 语法\n",
    "Python语言 break 语句语法：\n",
    "```\n",
    "break\n",
    "```\n",
    "\n",
    "# 流程图\n",
    "\n",
    "![break-流程图](https://pptwinpics.oss-cn-beijing.aliyuncs.com/break-%E6%B5%81%E7%A8%8B%E5%9B%BE_20191126150556.jpg)\n",
    "\n",
    "# 实例"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 1,
   "metadata": {},
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "当前字母 : P\n",
      "当前字母 : y\n",
      "当前字母 : t\n",
      "当前变量值 : 10\n",
      "当前变量值 : 9\n",
      "当前变量值 : 8\n",
      "当前变量值 : 7\n",
      "当前变量值 : 6\n",
      "Good bye!\n"
     ]
    }
   ],
   "source": [
    "for letter in 'Python':     # 第一个实例\n",
    "   if letter == 'h':\n",
    "      break\n",
    "   print('当前字母 :', letter)\n",
    "  \n",
    "var = 10                    # 第二个实例\n",
    "while var > 0:              \n",
    "   print('当前变量值 :', var)\n",
    "   var = var -1\n",
    "   if var == 5:   # 当变量 var 等于 5 时退出循环\n",
    "      break\n",
    " \n",
    "print(\"Good bye!\")"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {},
   "outputs": [],
   "source": []
  }
 ],
 "metadata": {
  "kernelspec": {
   "display_name": "Python 3",
   "language": "python",
   "name": "python3"
  },
  "language_info": {
   "codemirror_mode": {
    "name": "ipython",
    "version": 3
   },
   "file_extension": ".py",
   "mimetype": "text/x-python",
   "name": "python",
   "nbconvert_exporter": "python",
   "pygments_lexer": "ipython3",
   "version": "3.7.5"
  }
 },
 "nbformat": 4,
 "nbformat_minor": 2
}
